Encoding:

POOL32A

000000

rt

rs

rd

SUBU.PH

01100001101

POOL32A

000000

rt

rs

rd

SUBU_S.PH

11100001101

6

5

5

5

11

SPECIAL3

011111

rs

rt

rd

SUBU.PH

01001

ADDU.QB

010000

SPECIAL3

011111

rs

rt

rd

SUBU_S.PH

01101

ADDU.QB

010000

6

5

5

5

5

6

Format:

SUBU[_S].PH 

Subtract Unsigned Integer Halfwords

SUBU.PH    rd, rs, rt

microMIPSDSP-R2

Subtract Unsigned Integer Halfwords

SUBU_S.PH  rd, rs, rt

microMIPSDSP-R2

Subtract Unsigned Integer Halfwords

Purpose:

Subtract Unsigned Integer Halfwords

Element-wise subtraction of pairs of unsigned integer halfwords, with optional saturation.

Description:

rd = sign_extend(sat16(rs31..16 - rt31..16) || sat16(rs15..0 - rt15..0))

The two right-most unsigned integer halfwords in register rs are subtracted from the corresponding unsigned integer halfwords in register rt. The unsigned results are then written to the corresponding element in destination register rd.

In the saturating version of the instruction, if either subtractio n results in an underflow the result is clamped to the minimum unsigned integer halfword value (0x0000 hexadecimal), before being written to the destination register rd.

Bit 31 of the result is extended into the 32 most-significant bits of the destination register.

For both instruction variants, if either subtraction causes an underflow the instruction writes a 1 to bit 20 in the

DSPControl register in the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be a value in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBU.PH:
   tempB15..0 = subtractU16U16( GPR[rt]31..16 , GPR[rs]31..16 )
   tempA15..0 = subtractU16U16( GPR[rt]15..0 , GPR[rs]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
SUBU_S.PH:
   tempB15..0 = satU16SubtractU16U16( GPR[rt]31..16 , GPR[rs]31..16 )
   tempA15..0 = satU16SubtractU16U16( GPR[rt]15..0 , GPR[rs]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function subtractU16U16( a15..0, b15..0 ) 
   temp16..0 = ( 0 || a15..0 ) - ( 0 || b15..0 )
   if ( temp16 = 1 ) then
      DSPControlouflag:20 = 1 
   endif
   return temp15..0
endfunction subtractU16U16 
function satU16SubtractU16U16( a15..0, b15..0 ) 
   temp16..0 = ( 0 || a15..0 ) - ( 0 || b15..0 )
   if ( temp16 = 1 ) then
      temp15..0 = 0x0000
      DSPControlouflag:20 = 1 
   endif
   return temp15..0
endfunction satU16SubtractU16U16

Exceptions:

Reserved Instruction, DSP Disabled